package com.th.common.exception;


import com.alibaba.druid.wall.violation.ErrorCode;
import com.th.common.response.ResultData;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务逻辑异常 Exception
 * @author tuhang
 */
@Data
@EqualsAndHashCode(callSuper = true)
public final class BaseServiceException extends RuntimeException {

    /**
     * 业务错误码
     *
     * @see
     */
    private Integer code;
    /**
     * 错误提示
     */
    private String message;

    /**
     * 通用错误对象
     */
    private ResultData resultData;

    /**
     * 空构造方法，避免反序列化问题
     */
    public BaseServiceException() {
    }

    public BaseServiceException(ResultData resultData) {
        this.resultData = resultData;
    }


    public BaseServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public BaseServiceException setCode(Integer code) {
        this.code = code;
        return this;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public BaseServiceException setMessage(String message) {
        this.message = message;
        return this;
    }

}
